package com.geek.framework.study.event.distributed;

/**
 * @Author: ysq
 * @Date: 2021/9/1
 * @Description: 分布式事件_订阅者
 */
public class DistributedEventSubscriber {

  //  订阅者 需要先启动起来
  public static void main(String[] args) {
    DistributedEventPublisher eventPublisher = new DistributedEventPublisher("redis://127.0.0.1:6379");

    // Customized Listener
    eventPublisher.addEventListener(event -> {
      if (!(event instanceof DistributedEventObject)) {
        System.out.printf("[Thread : %s] Handles %s[Source : %s]\n",
                Thread.currentThread().getName(),
                event.getClass().getSimpleName(),
                event.getSource());
      }
    });

    eventPublisher.close();
  }
}
